﻿//Created by Action Script Viewer - http://www.buraks.com/asv
package Display.Toaster {
    import flash.events.*;
    import Engine.Managers.*;
    import flash.display.*;
    import Classes.*;
    import Display.*;
    import flash.text.*;

    public class ItemToaster extends Toaster {

        private var m_bg:Sprite;
        private var m_btnClose:SimpleButton;
        private var m_iconContainer:Sprite;
        private var m_tfTitle:TextField;
        private var m_tfBody:TextField;
        private var m_titleFormat:TextFormat;
        private var m_bodyFormat:TextFormat;
        private var m_icon:DisplayObject;

        public function ItemToaster(_arg1:String, _arg2:String, _arg3:String=null){
            m_duration = 5000;
            this.m_bg = new EmbeddedArt.hud_nghbr_toasters_bg();
            this.m_bg.width = 415;
            addChild(this.m_bg);
            this.m_iconContainer = new Sprite();
            this.m_iconContainer.addChild(new EmbeddedArt.hud_nghbr_toasters_frame());
            this.m_iconContainer.x = 7;
            this.m_iconContainer.y = 7;
            addChild(this.m_iconContainer);
            this.m_btnClose = new SimpleButton(new EmbeddedArt.hud_nghbr_toasters_close_up(), new EmbeddedArt.hud_nghbr_toasters_close_over(), new EmbeddedArt.hud_nghbr_toasters_close_up(), new EmbeddedArt.hud_nghbr_toasters_close_up());
            this.m_btnClose.x = (this.m_bg.width - this.m_btnClose.width);
            this.m_btnClose.addEventListener(MouseEvent.CLICK, this.btnCloseClickHandler, false, 0, true);
            addChild(this.m_btnClose);
            if (_arg3){
                LoadingManager.load(_arg3, this.iconLoadHandler);
            };
            var _local4:Number = TextFieldUtil.getLocaleFontSizeByRatio(20, 0.8, null);
            this.m_titleFormat = new TextFormat(EmbeddedArt.TITLE_FONT, _local4, EmbeddedArt.titleColor);
            this.m_bodyFormat = new TextFormat(EmbeddedArt.DEFAULT_FONT_NAME_BOLD, 14, EmbeddedArt.brownTextColor);
            this.m_tfTitle = new TextField();
            this.m_tfTitle.antiAliasType = AntiAliasType.ADVANCED;
            this.m_tfTitle.gridFitType = GridFitType.PIXEL;
            this.m_tfTitle.embedFonts = true;
            this.m_tfTitle.autoSize = TextFieldAutoSize.LEFT;
            this.m_tfTitle.defaultTextFormat = this.m_titleFormat;
            this.m_tfTitle.text = _arg1;
            this.m_tfTitle.selectable = false;
            TextFieldUtil.formatSmallCaps(this.m_tfTitle, new TextFormat(EmbeddedArt.TITLE_FONT, _local4));
            this.m_tfTitle.filters = EmbeddedArt.titleFilters;
            addChild(this.m_tfTitle);
            this.m_tfBody = new TextField();
            this.m_tfBody.antiAliasType = AntiAliasType.ADVANCED;
            this.m_tfBody.gridFitType = GridFitType.PIXEL;
            this.m_tfBody.embedFonts = true;
            this.m_tfBody.width = 280;
            this.m_tfBody.multiline = true;
            this.m_tfBody.wordWrap = true;
            this.m_tfBody.selectable = false;
            this.m_tfBody.defaultTextFormat = this.m_bodyFormat;
            this.m_tfBody.text = _arg2;
            addChild(this.m_tfBody);
            this.draw();
        }
        override public function get displayHeight():Number{
            return ((this.m_bg.height - 30));
        }
        protected function draw():void{
            this.m_tfTitle.x = (this.m_tfBody.x = 125);
            this.m_tfTitle.y = 10;
            this.m_tfBody.y = (this.m_tfTitle.y + this.m_tfTitle.height);
            if (this.m_icon){
                this.m_icon.x = ((this.m_iconContainer.width - this.m_icon.width) * 0.5);
                this.m_icon.y = ((this.m_iconContainer.height - this.m_icon.height) * 0.5);
            };
            this.m_bg.height = ((this.m_tfBody.y + this.m_tfBody.height) + 25);
        }
        private function iconLoadHandler(_arg1:Event):void{
            this.m_icon = _arg1.currentTarget["content"];
            if (this.m_icon){
                this.m_iconContainer.addChild(this.m_icon);
                this.draw();
            };
        }
        private function btnCloseClickHandler(_arg1:MouseEvent):void{
            close();
        }

    }
}//package Display.Toaster 
